 package server.events;

 import client.MapleCharacter;
 import client.MapleTraitType;
 import handling.channel.ChannelServer;
 import handling.world.party.MaplePartyCharacter;
 import java.awt.Point;
 import server.Timer;
 import server.life.MapleLifeFactory;
 import server.maps.MapleMap;
 import server.quest.MapleQuest;
 import tools.Randomizer;
 import tools.packet.UIPacket;























 public class MapleDojoAgent
 {
   private static final int baseAgentMapId = 970030000;
/*  40 */   private static final Point point1 = new Point(140, 0);
/*  41 */   private static final Point point2 = new Point(-193, 0);
/*  42 */   private static final Point point3 = new Point(355, 0);

   public static boolean warpStartAgent(MapleCharacter c, boolean party) {
/*  45 */     int stage = 1;
/*  46 */     int mapid = 970030100;

/*  48 */     ChannelServer ch = c.getClient().getChannelServer();
/*  49 */     for (int i = 970030100; i < 970030115; i++) {
/*  50 */       MapleMap map = ch.getMapFactory().getMap(i);
/*  51 */       if (map.getCharactersSize() == 0) {
/*  52 */         clearMap(map, false);
/*  53 */         c.changeMap(map, map.getPortal(0));
/*  54 */         map.respawn(true);
/*  55 */         return true;
       }
     }
/*  58 */     return false;
   }

   public static boolean warpNextMap_Agent(MapleCharacter c, boolean fromResting) {
/*  62 */     int currentmap = c.getMapId();
/*  63 */     int thisStage = (currentmap - 970030000) / 100;

/*  65 */     MapleMap map = c.getMap();
/*  66 */     if (map.getSpawnedMonstersOnMap() > 0) {
/*  67 */       return false;
     }
/*  69 */     if (!fromResting) {
/*  70 */       clearMap(map, true);
/*  71 */       c.modifyCSPoints(1, 40, true);
     }
/*  73 */     ChannelServer ch = c.getClient().getChannelServer();
/*  74 */     if (currentmap >= 970032700 && currentmap <= 970032800) {
/*  75 */       map = ch.getMapFactory().getMap(970030000);
/*  76 */       c.changeMap(map, map.getPortal(0));
/*  77 */       return true;
     }
/*  79 */     int nextmapid = 970030000 + (thisStage + 1) * 100;
/*  80 */     for (int i = nextmapid; i < nextmapid + 7; i++) {
/*  81 */       map = ch.getMapFactory().getMap(i);
/*  82 */       if (map.getCharactersSize() == 0) {
/*  83 */         clearMap(map, false);
/*  84 */         c.changeMap(map, map.getPortal(0));
/*  85 */         c.updateInfoQuest(7281, "item=0;chk=0;cNum=0;sec=15;stage=" + (thisStage - 1) + ";lBonus=0");
/*  86 */         c.updateInfoQuest(7281, "item=0;chk=0;cNum=0;sec=15;stage=" + thisStage + ";lBonus=0");
/*  87 */         c.updateInfoQuest(7214, "15");
/*  88 */         c.updateInfoQuest(7215, "stage=" + (thisStage + 1) + ";type=1;token=3");
/*  89 */         c.updateInfoQuest(7215, "stage=" + (thisStage + 1) + ";type=1;token=3");
/*  90 */         map.respawn(true);
/*  91 */         return true;
       }
     }
/*  94 */     return false;
   }

   public static boolean warpStartDojo(MapleCharacter c, boolean party, MapleMap currentmap) {
/*  98 */     int stage = 1;
/*  99 */     if (party || stage <= -1 || stage > 38) {
/* 100 */       stage = 1;
     }
/* 102 */     int mapid = currentmap.getId();
/* 103 */     boolean canenter = false;
/* 104 */     ChannelServer ch = c.getClient().getChannelServer(); int x;
/* 105 */     for (x = 0; x < 10; x++) {
/* 106 */       boolean canenterr = true;
/* 107 */       for (int i = 1; i <= 47; i++) {
/* 108 */         MapleMap mapleMap = ch.getMapFactory().getMap(925020000 + 100 * i + x);
/* 109 */         if (mapleMap.getCharactersSize() > 0) {
/* 110 */           canenterr = false;
           break;
         }
/* 113 */         clearMap(mapleMap, false);
       }

/* 116 */       if (canenterr) {
/* 117 */         canenter = true;
/* 118 */         mapid += x;
         break;
       }
     }
/* 122 */     for (x = 0; x < 10; x++) {
/* 123 */       boolean canenterr = true;
/* 124 */       for (int i = 1; i <= 47; i++) {
/* 125 */         MapleMap mapleMap = ch.getMapFactory().getMap(925030000 + 100 * i + x);
/* 126 */         if (mapleMap.getCharactersSize() > 0) {
/* 127 */           canenterr = false;
           break;
         }
/* 130 */         clearMap(mapleMap, false);
       }

/* 133 */       if (canenterr) {
/* 134 */         canenter = true;
/* 135 */         mapid += x;
         break;
       }
     }
/* 139 */     MapleMap map = ch.getMapFactory().getMap(mapid);
/* 140 */     MapleMap mapidd = c.getMap();
/* 141 */     if (canenter) {
/* 142 */       if (party && c.getParty() != null) {
/* 143 */         for (MaplePartyCharacter mem : c.getParty().getMembers()) {
/* 144 */           MapleCharacter chr = mapidd.getCharacterById(mem.getId());
/* 145 */           if (chr != null && chr.isAlive()) {
/* 146 */             changeMap(chr, map);
           }
         }
       } else {
/* 150 */         changeMap(c, map);
       }
/* 152 */       spawnMonster(map, stage);
     }
/* 154 */     return canenter;
   }

   private static void changeMap(MapleCharacter player, MapleMap map) {
/* 158 */     MapleQuest quest = MapleQuest.getInstance(7214);
/* 159 */     player.getQuestNAdd(quest).setCustomData("0");
/* 160 */     player.updateQuest(player.getQuestNAdd(quest));
/* 161 */     player.updateInfoQuest(7218, "1");
/* 162 */     player.updateOneInfo(7281, "sec", "0");
/* 163 */     player.updateOneInfo(7215, "sTime", String.valueOf(System.currentTimeMillis()));
/* 164 */     player.changeMap(map, map.getPortal(0));
   }

   public static void failed(MapleCharacter c) {
/* 168 */     MapleMap currentmap = c.getMap();
/* 169 */     MapleMap deadMap = c.getClient().getChannelServer().getMapFactory().getMap(925020002);
/* 170 */     if (c.getParty() != null && c.getParty().getMembers().size() > 1) {
/* 171 */       for (MaplePartyCharacter mem : c.getParty().getMembers()) {
/* 172 */         MapleCharacter chr = currentmap.getCharacterById(mem.getId());
/* 173 */         if (chr != null) {
/* 174 */           chr.changeMap(deadMap, deadMap.getPortal(0));
         }
       }
     }
   }









   public static boolean warpNextMap(MapleCharacter c, boolean fromResting, MapleMap currentmap) {
     try {
/* 190 */       int temp = (currentmap.getId() - 925000000) / 100;
/* 191 */       int thisStage = temp - temp / 100 * 100;
/* 192 */       int points = getDojoPoints(thisStage);
/* 193 */       ChannelServer ch = c.getClient().getChannelServer();
/* 194 */       MapleMap deadMap = ch.getMapFactory().getMap(925020002);
/* 195 */       if (!c.isAlive()) {
/* 196 */         c.changeMap(deadMap, deadMap.getPortal(0));
/* 197 */         return true;
       }
/* 199 */       MapleMap map = ch.getMapFactory().getMap(currentmap.getId() + 100);
/* 200 */       if (!fromResting && map != null) {
/* 201 */         clearMap(currentmap, true);
/* 202 */         if (c.getParty() != null && c.getParty().getMembers().size() > 1) {
/* 203 */           for (MaplePartyCharacter mem : c.getParty().getMembers()) {
/* 204 */             MapleCharacter chr = currentmap.getCharacterById(mem.getId());
/* 205 */             if (chr != null) {
/* 206 */               int point = points * 3;
/* 207 */               c.getTrait(MapleTraitType.will).addExp(points, c);
/* 208 */               chr.modifyCSPoints(1, point * 4, true);
/* 209 */               int dojo = chr.getIntRecord(150100) + point;
/* 210 */               chr.getQuestNAdd(MapleQuest.getInstance(150100)).setCustomData(String.valueOf(dojo));
             }
           }
         } else {

/* 215 */           int point = points * 4;
/* 216 */           c.getTrait(MapleTraitType.will).addExp(points, c);
/* 217 */           c.modifyCSPoints(1, point * 4, true);
/* 218 */           int dojo = c.getIntRecord(150100) + point;
/* 219 */           c.getQuestNAdd(MapleQuest.getInstance(150100)).setCustomData(String.valueOf(dojo));
         }
       }


/* 224 */       if (currentmap.getId() >= 925023800 && currentmap.getId() <= 925023814) {
/* 225 */         MapleMap lastMap = ch.getMapFactory().getMap(925020003);

/* 227 */         if (c.getParty() != null && c.getParty().getMembers().size() > 1) {
/* 228 */           for (MaplePartyCharacter mem : c.getParty().getMembers()) {
/* 229 */             MapleCharacter chr = currentmap.getCharacterById(mem.getId());
/* 230 */             if (chr != null) {
/* 231 */               if (!chr.isAlive()) {
/* 232 */                 chr.addHP(50);
               }
/* 234 */               chr.changeMap(lastMap, lastMap.getPortal(1));
/* 235 */               int point = points * 3;
/* 236 */               c.getTrait(MapleTraitType.will).addExp(points, c);
/* 237 */               int dojo = chr.getIntRecord(150100) + point;
/* 238 */               chr.getQuestNAdd(MapleQuest.getInstance(150100)).setCustomData(String.valueOf(dojo));

/* 240 */               chr.modifyCSPoints(1, 5000, true);
             }
           }
         } else {
/* 244 */           c.changeMap(lastMap, lastMap.getPortal(1));
/* 245 */           int point = points * 4;
/* 246 */           c.getTrait(MapleTraitType.will).addExp(points, c);
/* 247 */           int dojo = c.getIntRecord(150100) + point;
/* 248 */           c.getQuestNAdd(MapleQuest.getInstance(150100)).setCustomData(String.valueOf(dojo));

/* 250 */           c.modifyCSPoints(1, (currentmap.getCharactersSize() > 1) ? 5000 : 7500, true);
         }
/* 252 */         return true;
       }
/* 254 */       if (currentmap.getId() != 925020001)
       {

/* 257 */         if (currentmap.getId() == 925021100) {
/* 258 */           MapleMap mappzz = ch.getMapFactory().getMap(925020003);
/* 259 */           c.changeMap(mappzz, mappzz.getPortal(1));
/* 260 */         } else if (currentmap.getId() == 925032300) {
/* 261 */           MapleMap mappzz = ch.getMapFactory().getMap(925020003);
/* 262 */           c.changeMap(mappzz, mappzz.getPortal(1));
/* 263 */           c.getClient().getSession().write(UIPacket.sendOpenWindow(72));
         }
         else {

/* 267 */           if (map != null && map.getCharactersSize() == 0) {
/* 268 */             clearMap(map, false);
/* 269 */             updateQuestInfoAndChangeMap(c, currentmap, map, thisStage);








/* 278 */             spawnMonster(map, thisStage + 1);
/* 279 */             return true;
/* 280 */           }  if (map != null) {
/* 281 */             int basemap = currentmap.getId() / 100 * 100 + 100;
/* 282 */             for (int x = 0; x < 10; x++) {
/* 283 */               MapleMap mapz = ch.getMapFactory().getMap(basemap + x);
/* 284 */               if (mapz.getCharactersSize() == 0) {
/* 285 */                 clearMap(mapz, false);
/* 286 */                 updateQuestInfoAndChangeMap(c, currentmap, mapz, thisStage);



/* 290 */                 spawnMonster(mapz, thisStage + 1);
/* 291 */                 return true;
               }
             }
           }
/* 295 */           MapleMap mappz = ch.getMapFactory().getMap(925020003);
/* 296 */           int diff = (currentmap.getId() % 1000000 / 10000 - 1) / 2;
/* 297 */           String mode = (diff == 0) ? "普通模式" : ((diff == 1) ? "困难模式" : "排行榜模式");
/* 298 */           int exp = 306951 * (1 + diff);
/* 299 */           if (c.getParty() != null) {
/* 300 */             for (MaplePartyCharacter mem : c.getParty().getMembers()) {
/* 301 */               MapleCharacter chr = currentmap.getCharacterById(mem.getId());
/* 302 */               if (chr != null) {
/* 303 */                 chr.dropMessage(5, "你在" + mode + "下通关了武陵道场。获得了" + exp + "点经验值。");
/* 304 */                 chr.changeMap(mappz, mappz.getPortal(0));
               }
             }
           } else {
/* 308 */             c.gainExp(exp, true, true, true);
/* 309 */             if (c.getEventCount("Dojo_VALUE") < 5) {
/* 310 */               c.setEventCount("Dojo_VALUE");
/* 311 */               c.setEventCount("ACTIVE_VALUE");
             }
/* 313 */             c.dropMessage(5, "你在" + mode + "下通关了武陵道场。获得了" + exp + "点经验值。");
/* 314 */             c.changeMap(mappz, mappz.getPortal(0));
           }
         }  }
/* 317 */     } catch (Exception rm) {
/* 318 */       rm.printStackTrace();
     }

/* 321 */     return false;
   }

   private static void updateQuestInfoAndChangeMap(MapleCharacter c, MapleMap currentmap, MapleMap mapz, int thisStage) {
/* 325 */     if (c.getParty() != null) {
/* 326 */       for (MaplePartyCharacter mem : c.getParty().getMembers()) {
/* 327 */         MapleCharacter chr = currentmap.getCharacterById(mem.getId());
/* 328 */         if (chr != null) {
/* 329 */           if (!chr.isAlive()) {
/* 330 */             chr.addHP(50);
           }
/* 332 */           if (thisStage % 6 == 0) {
/* 333 */             chr.updateOneInfo(7215, "sTime", String.valueOf(System.currentTimeMillis()));
           }
/* 335 */           chr.changeMap(mapz, mapz.getPortal(0));
         }
       }
     } else {
/* 339 */       if (thisStage % 6 == 0) {
/* 340 */         c.updateOneInfo(7215, "sTime", String.valueOf(System.currentTimeMillis()));
       }
/* 342 */       c.changeMap(mapz, mapz.getPortal(0));
     }
   }

   private static void clearMap(MapleMap map, boolean check) {
/* 347 */     if (check && 
/* 348 */       map.getCharactersSize() != 0) {
       return;
     }

/* 352 */     map.resetFully();
   }


   private static int getDojoPoints(int stage) {
/* 357 */     switch (stage) {
       case 1:
       case 2:
       case 3:
       case 4:
       case 5:
/* 363 */         return 1;
       case 7:
       case 8:
       case 9:
       case 10:
       case 11:
/* 369 */         return 2;
       case 13:
       case 14:
       case 15:
       case 16:
       case 17:
/* 375 */         return 3;
       case 19:
       case 20:
       case 21:
       case 22:
       case 23:
/* 381 */         return 4;
       case 25:
       case 26:
       case 27:
       case 28:
       case 29:
/* 387 */         return 5;
       case 31:
       case 32:
       case 33:
       case 34:
       case 35:
/* 393 */         return 6;
       case 37:
       case 38:
/* 396 */         return 7;
     }
/* 398 */     return 0;
   }












   private static void spawnMonster(MapleMap map, int stage) {
/* 413 */     int mobid, mob1[] = { 9300209, 9300184, 9300191, 9300185 };
/* 414 */     int stage1 = mob1[Randomizer.nextInt(mob1.length)];
/* 415 */     int[] mob2 = { 9300196, 9300187, 9300194, 9300190 };
/* 416 */     int stage2 = mob2[Randomizer.nextInt(mob2.length)];
/* 417 */     int[] mob3 = { 9300189, 9300204 };
/* 418 */     int stage3 = mob3[Randomizer.nextInt(mob3.length)];
/* 419 */     int[] mob4 = { 9300203, 9300199 };
/* 420 */     int stage4 = mob4[Randomizer.nextInt(mob4.length)];
/* 421 */     int[] mob5 = { 9300186, 9300197, 9300193 };
/* 422 */     int stage5 = mob5[Randomizer.nextInt(mob5.length)];
/* 423 */     int[] mob6 = { 9300207, 9300200, 9300195 };
/* 424 */     int stage6 = mob6[Randomizer.nextInt(mob6.length)];
/* 425 */     int[] mob7 = { 9300192, 9300198 };
/* 426 */     int stage7 = mob7[Randomizer.nextInt(mob7.length)];
/* 427 */     int[] mob8 = { 9300205 };
/* 428 */     int stage8 = mob8[Randomizer.nextInt(mob8.length)];
/* 429 */     int[] mob9 = { 9300206 };
/* 430 */     int stage9 = mob9[Randomizer.nextInt(mob9.length)];
/* 431 */     int[] mob10 = { 9300215 };
/* 432 */     int stage10 = mob10[Randomizer.nextInt(mob10.length)];

/* 434 */     switch (stage) {
       case 1:
/* 436 */         mobid = stage1;
         break;
       case 2:
/* 439 */         mobid = stage2;
         break;
       case 3:
/* 442 */         mobid = stage3;
         break;
       case 4:
/* 445 */         mobid = stage4;
         break;
       case 5:
/* 448 */         mobid = stage5;
         break;
       case 7:
/* 451 */         mobid = stage6;
         break;
       case 8:
/* 454 */         mobid = stage7;
         break;
       case 9:
/* 457 */         mobid = stage8;
         break;
       case 10:
/* 460 */         mobid = stage9;
         break;
       case 11:
/* 463 */         if (map.getId() == 925021100) {
/* 464 */           mobid = stage10; break;
         }
/* 466 */         mobid = 9300201;
         break;

       case 13:
/* 470 */         mobid = 9300188;
         break;
       case 14:
/* 473 */         mobid = 9300211;
         break;
       case 15:
/* 476 */         mobid = 9300208;
         break;
       case 16:
/* 479 */         mobid = 9300214;
         break;
       case 17:
/* 482 */         mobid = 9305134;
         break;
       case 19:
/* 485 */         mobid = 9300213;
         break;
       case 20:
/* 488 */         mobid = 9305136;
         break;
       case 21:
/* 491 */         mobid = 9305137;
         break;
       case 22:
/* 494 */         mobid = 9305138;
         break;
       case 23:
/* 497 */         mobid = 9305139;
         break;


















































       default:
         return;
     }


















































/* 602 */     if (mobid != 0) {
/* 603 */       int rand = Randomizer.nextInt(3);

/* 605 */       Timer.MapTimer.getInstance().schedule(() -> map.spawnMonsterWithEffect(MapleLifeFactory.getMonster(mobid), 15, (rand == 0) ? point1 : ((rand == 1) ? point2 : point3)), 3000L);
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\server\events\MapleDojoAgent.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */